{- |
Module      :  ExampleGrids.hs
Description :  Grids for testing purposes
Copyright   :  (c) Michal Parusinski
License     :  GPLv3

Maintainer  :  mparusinski@googlemail.com
Stability   :  NOT APPLICABLE
Portability :  portable
-}

module ExampleGrids where 

import qualified Data.Array as Array

import Symbols
import SudokuGrid

-- The below function is suprisingly elegant :)
convertToIndices doublelist = do 
  let colSize = length doublelist
  let rowSize = length (head doublelist)
  i <- [1..rowSize]
  j <- [1..colSize]
  let elem    = (doublelist !! (i-1)) !! (j-1)
  return ((i,j), elem)

-- List to test the function above
testList = [[1,2],[3,4]]

-- Example of Grids used for testing

exampleGridList1 =
    [[ Nothing, Just Nine, Just Eight, 
       Nothing, Nothing, Nothing,
       Just Four, Just Seven, Just Three ],
     [ Just Six, Just One, Just Two,
       Just Three, Just Four, Just Seven,
       Just Five, Just Eight, Just Nine ],
     [ Nothing, Nothing, Just Three,
       Nothing, Nothing, Nothing,
       Just One, Just Six, Just Two ],
     [ Nothing, Just Three, Just Five,
       Just Four, Nothing, Just One,
       Just Eight, Nothing, Just Six ],
     [ Nothing, Nothing, Just Six, 
       Nothing, Nothing, Nothing,
       Just Three, Nothing, Just One ],
     [ Nothing, Nothing, Just One,
       Just Six, Nothing, Just Three,
       Just Two, Nothing, Just Seven ],
     [ Nothing, Nothing, Just Nine,
       Nothing, Nothing, Just Four,
       Just Six, Just Three, Just Eight ],
     [ Just Three, Just Six, Just Four,
       Just Two, Just Eight, Just Nine,
       Just Seven, Just One, Just Five ],
     [ Nothing, Just Eight, Just Seven, 
       Nothing, Just Three, Nothing,
       Just Nine, Just Two, Just Four ]]
       
exampleGrid1
    = Grid size $ Array.array ((1,1),(size,size)) indices
    where  size    = length (symbols :: [DefaultSymbol])
           indices = convertToIndices exampleGridList1

exampleGridList2 =
    [[ Nothing, Nothing, Nothing, 
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just One ],
     [ Nothing, Nothing, Nothing,
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just Two ],
     [ Nothing, Nothing, Nothing,
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just Three ],
     [ Nothing, Nothing, Nothing,
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just Four ],
     [ Nothing, Nothing, Nothing, 
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just Five ],
     [ Nothing, Nothing, Nothing,
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just Six ],
     [ Nothing, Nothing, Nothing,
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just Seven ],
     [ Nothing, Nothing, Nothing,
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just Eight ],
     [ Nothing, Nothing, Nothing, 
       Nothing, Nothing, Nothing,
       Nothing, Nothing, Just Nine ]]

modifierList 
    = [ ((i, 9 :: Int), (symbols :: [DefaultSymbol]) !! (i-1)) | i <- [1..9] ]

exampleGrid2
    = Grid size $ Array.array ((1,1),(size,size)) indices
    where  size    = length (symbols :: [DefaultSymbol])
           indices = convertToIndices exampleGridList2

